package com.ruoyi.web.controller.business;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.TbOutGood;
import com.ruoyi.system.service.ITbOutGoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 离场货品图片信息Controller
 * 
 * @author ruoyi
 * @date 2024-05-27
 */
@RestController
@RequestMapping("/business/good-out")
public class TbOutGoodController extends BaseController
{
    @Autowired
    private ITbOutGoodService tbOutGoodService;

    /**
     * 查询离场货品图片信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TbOutGood tbOutGood)
    {
        startPage();
        List<TbOutGood> list = tbOutGoodService.selectTbOutGoodList(tbOutGood);
        return getDataTable(list);
    }

    /**
     * 导出离场货品图片信息列表
     */
    @Log(title = "离场货品图片信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbOutGood tbOutGood)
    {
        List<TbOutGood> list = tbOutGoodService.selectTbOutGoodList(tbOutGood);
        ExcelUtil<TbOutGood> util = new ExcelUtil<TbOutGood>(TbOutGood.class);
        util.exportExcel(response, list, "离场货品图片信息数据");
    }

    /**
     * 获取离场货品图片信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbOutGoodService.selectTbOutGoodById(id));
    }

    /**
     * 新增离场货品图片信息
     */
    @Log(title = "离场货品图片信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbOutGood tbOutGood)
    {
        return toAjax(tbOutGoodService.insertTbOutGood(tbOutGood));
    }

    /**
     * 修改离场货品图片信息
     */
    @Log(title = "离场货品图片信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbOutGood tbOutGood)
    {
        return toAjax(tbOutGoodService.updateTbOutGood(tbOutGood));
    }

    /**
     * 删除离场货品图片信息
     */
    @Log(title = "离场货品图片信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbOutGoodService.deleteTbOutGoodByIds(ids));
    }
}
